package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.Checking;
import cn.wolfcode.car.mapper.CheckingMapper;
import cn.wolfcode.car.qo.CheckingQueryObject;
import cn.wolfcode.car.service.ICheckingService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CheckingServiceImpl implements ICheckingService {
    @Autowired
    private CheckingMapper checkingMapper;
    @Override
    public int delete(Long id) {
        return checkingMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int save(Checking record) {
        return checkingMapper.insert(record);
    }

    @Override
    public Checking get(Long id) {
        return checkingMapper.selectByPrimaryKey(id);
    }


    @Override
    public PageInfo<Checking> selectForPage(CheckingQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Checking> list = checkingMapper.selectForPage(qo);
        return new PageInfo<>(list);
    }


    @Override
    public int update(Checking record) {
        return checkingMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Checking> listAll() {
        return checkingMapper.selectAll();
    }

    @Override
    public Checking selectBychencingId(Long id) {
        return checkingMapper.selectBychencingId(id);
    }
}
